package com.example.carbonbackend.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.carbonbackend.common.BaseResponse;
import com.example.carbonbackend.common.ResultUtils;
import com.example.carbonbackend.model.dto.companyUser.UserGetCompanyRequest;
import com.example.carbonbackend.model.entity.Company;
import com.example.carbonbackend.service.CompanyService;
import com.example.carbonbackend.service.CompanyUserService;
import org.apache.catalina.util.RequestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/companyuser")
public class CompanyUserController {
    @Autowired
    CompanyUserService companyUserService;
    @Autowired
    CompanyService companyService;
    @PostMapping("/list/company")
    public BaseResponse<Page<Company>> getCompany(@RequestBody UserGetCompanyRequest request){
        int pageSize=request.getPageSize();
        int current=request.getCurrent();
        Page<Company> companyPage=companyService.page(new Page<>(current,pageSize),
                companyUserService.getCompany(request));
        return ResultUtils.success(companyPage);
    }
}
